package com.zhentao.controller;

import com.zhentao.dtos.Result;
import com.zhentao.model.entity.product.Product;
import com.zhentao.model.entity.product.ProductSku;
import com.zhentao.service.ProductSkuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("productSku")
public class ProductSkuController {
    @Autowired
    private ProductSkuService productSkuService;

    @RequestMapping("findById")
    public Result findById( Long id ) {
        ProductSku productSku = null;
        try {
            productSku = productSkuService.findById( id );
            return Result.success( productSku );
        } catch (Exception e) {
            e.printStackTrace();
        }
        return Result.error();
    }

    @RequestMapping("findAllById")
    public Result findAllById( Long id ) {
        List< ProductSku > list = null;
        try {
            list = productSkuService.findAllById( id );
            return Result.success( list );
        } catch (Exception e) {
            e.printStackTrace();
        }
        return Result.error();
    }
}
